package com.hbo.timer.quartz;

import org.quartz.DisallowConcurrentExecution;
import org.quartz.Job;
import org.quartz.JobDataMap;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.quartz.PersistJobDataAfterExecution;

import java.util.Date;

/**
 * @author songxulin
 * @date 2022/3/19
 */
@DisallowConcurrentExecution
@PersistJobDataAfterExecution
public class MyJob  implements Job {
    public void execute(JobExecutionContext context) throws JobExecutionException {
        JobDataMap jobDataMap = context.getJobDetail().getJobDataMap();
        JobDataMap mergedJobDataMap = context.getTrigger().getJobDataMap();
        JobDataMap mergedJobDataMap1 = context.getMergedJobDataMap();
        System.out.println(new Date());
//        System.out.println("jobDataMap"+jobDataMap.get("job"));
//        System.out.println("mergedJobDataMap"+mergedJobDataMap.get("trigger"));
//        System.out.println("mergedJobDataMap1"+mergedJobDataMap1);

        try {
            System.out.println(mergedJobDataMap.getInt("count"));
            System.out.println(jobDataMap.getInt("count"));
            Thread.sleep(3);
            mergedJobDataMap.put("count",mergedJobDataMap.getInt("count")+1);
            jobDataMap.put("count",jobDataMap.getInt("count")+1);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
